<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function Login(){
        $this->display();
    }
    public function Code(){
		 $config =    array(
		    'fontSize'    =>    25,    // 验证码字体大小
		    'length'      =>    4,     // 验证码位数
		    'useNoise'    =>    false, // 关闭验证码杂点
		);
		$Verify =     new \Think\Verify($config);
		$code = $Verify->entry();
    }
    public function logindo(){
    	$admin = M('Admin_user');
        $pass = $_POST['pass'];
        $_POST['pass']=md5($_POST['pass']);
        $res = $admin->where($_POST)->find();
    	if($res){
            $_POST['id']=$res['id'];
            $_POST['ip']=$_SERVER['REMOTE_ADDR'];
            $_POST['addtime'] =time();
            $_POST['number'] = $res['number']+1;
            $result = $admin->save($_POST);
            if($result){
                session_start();
                $_SESSION['user']=$_POST['user'];
                $_SESSION['pass']=$pass;
                $_SESSION['uid']=$res['id'];
                $this->redirect('Index/Index');
            }else{
                $this->error('登录失败1');
            }
    		
    	}else{
    		$this->error('登录失败2');
    	}
    }
}